import * as types from '../types'

export const DeviceFilters = {
    namespaced: true,
    state: {
        deviceArr: []
    },
    getters: {
        getterDeviceArr: state => state.deviceArr
    },
    mutations: {
        [types.SET_DEVICEFILTER](state, item) {
            if (item && state.deviceArr.indexOf(item) > -1) {
                state.deviceArr.splice(state.deviceArr.indexOf(item), 1);
            } else if (item && state.deviceArr.indexOf(item) == -1) {
                state.deviceArr.push(item);
            } else {
                state.deviceArr = []
            }
        }
    },
    actions: {
        GetSliderItemAction({ commit }, item) {
            commit(types.SET_DEVICEFILTER, item)
        }
    }
}
